package com.wsc.wisdomchina.activitity;

import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.amap.api.maps2d.model.LatLng;
import com.wsc.wisdomchina.BuildConfig;
import com.wsc.wisdomchina.R;
import com.wsc.wisdomchina.Tools.OpenExternalMapAppUtils;
import com.wsc.wisdomchina.Tools.Tools;
import com.wsc.wisdomchina.activitity.baseactivity.BaseActivity;
import com.wsc.wisdomchina.constant.Constant;
import com.wsc.wisdomchina.view.iphoneDialogBuilder;


public class AboutMineActivity extends BaseActivity {

    private ImageView regist_back;
    private TextView tv_headtitle,tv_version;
    private RelativeLayout user_procontrol;
    private RelativeLayout mPhone;
    private RelativeLayout mAddress;
    private RelativeLayout mWeb;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.aboutmine_layout);
        tv_version=(TextView) findViewById(R.id.tv_version);
        regist_back=(ImageView) findViewById(R.id.regist_back);
        regist_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        tv_headtitle=(TextView) findViewById(R.id.tv_headtitle);
        tv_headtitle.setText("关于我们");

        user_procontrol=(RelativeLayout) findViewById(R.id.user_procontrol);
        mPhone=(RelativeLayout) findViewById(R.id.rl_call);
        mAddress=(RelativeLayout) findViewById(R.id.rl_address);
        mWeb=(RelativeLayout) findViewById(R.id.rl_web);
        mPhone.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                showNoticeDialog();
            }
        });
        mWeb.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                Intent intent = new Intent();
                intent.setAction("android.intent.action.VIEW");
                Uri content_url = Uri.parse("http://www.ibenrobot.com");
                intent.setData(content_url);
                startActivity(intent);
            }
        });
        mAddress.setOnClickListener(new View.OnClickListener(){
            @Override
            public void onClick(View view) {
                try {
                    LatLng starLng = new LatLng(39.9444515586, 116.3479526857);
                    OpenExternalMapAppUtils.openMapDirection(AboutMineActivity.this, starLng.longitude + "", starLng.latitude + "",
                            "",
                            "", "", "宝蓝金融创新中心", "智慧中国");
                } catch (Exception e) {
                e.printStackTrace();
                }
            }
        });
        user_procontrol.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivity(new Intent(AboutMineActivity.this, ServiceProcontrolActivity.class));
            }
        });

        tv_version.setText("V"+BuildConfig.VERSION_NAME);
    }
    private void showNoticeDialog() {

        iphoneDialogBuilder idb = new iphoneDialogBuilder(this);
        idb.setTitle("联系我们");
        idb.setMessage("010-88388381");
        idb.setPositiveButton("拨打", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Intent intent = new Intent(Intent.ACTION_DIAL,Uri.parse("tel:"+"01088388381"));
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
            }
        });
        idb.setNegativeButton("取消", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });
        idb.show();

    }
}
